﻿using System;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using weikebuluo.DAL;
using weikebuluo.Model;
using weikebuluo.Common;


namespace weikebuluo.web.admin.user
{

    public partial class userlist : weikeweixin.web.admin.cs.userbase
    {
        a_user_dal userdal = new a_user_dal();
        JsonOperate JsonOperate = new JsonOperate();

        protected void Page_Load(object sender, EventArgs e)
        {

            switch (Request.QueryString["action"])
            {
                case "list":
                    list();
                    break;
                case "del":
                    del();
                    break;

            }
        }

        /// <summary>
        ///查询
        /// </summary>
        public void list()
        {
            string where = "user_level=1 ";

            if (!string.IsNullOrEmpty(Request.Form["keyword"]))
            {
                where += " and user_name='" + Request.Form["keyword"] + "'  or user_phone='" + Request.Form["keyword"] + "'";
            }

            int Page = int.Parse(Request.Form["page"]);
            int RecordCount = userdal.GetRecordCount(where);
            DataTable dtuser = userdal.GetListByPage(where, "user_id", ((Page - 1) * 10) + 1, (Page - 1) * 10 + 10).Tables[0];
            Response.Write(JsonOperate.GetDataGridJson(dtuser, RecordCount));
            Response.End();
        }

        private void del()
        {
            userdal.Delete(int.Parse(Request.QueryString["user_id"].Trim()));
        }
    }
}